package com.link.base.base.wechat.controller;

import com.link.base.base.wechat.service.JssdkService;
import com.link.core.cllog.LCLogger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * jssdk获取签名
 *
 * @author LiQun
 * @date 2019/3/12 10:11
 */
@Controller
@RequestMapping("/link/jssdk")
public class JssdkController {
    @Resource
    private JssdkService jssdkService;

    @RequestMapping("/getConfigParams")
    @ResponseBody
    public Map<String, Object> getConfigParams(HttpServletRequest request) throws Exception {
        Map<String, Object> result = new HashMap<>(16);
        try {
            String appId = request.getParameter("appId");
            String url = request.getParameter("url");
            result = jssdkService.getConfigParams(appId,url);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("message", e.getMessage());
        }
        return result;
    }
}
